import React, { useState } from 'react'
import Item from './Item'
import PubSub from 'pubsub-js'


export default function List() {
  const [result, setResult] = useState({isInit:true,isSearch:true,data:[]})
  {
    PubSub.subscribe("data", (_, data) => {
      setResult(data)
    })
  }
  return (
    <div className="row">
      {
        result.isInit ? <h2>请输入用户名搜索</h2> :
          result.isSearch ? <h2>搜索中</h2> :
            result.data.items.map(item => {
              return <Item key={item.id} item={item} />
            })
      }
    </div>
  )
}
